package com.corticon.dialogs.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * 
 * @author Yanglifan
 */
@Entity
@Table(name = "q_response")
public class Response extends AuditableEntity implements Serializable {

    private Long responseId;
    private String id;
    private String label;
    private String value;
    private Dialog dialog;
    private QuestionInSet question;
    private DataValidation dataValidation;

    public Response() {
    }

    public Response(String id, String label, String value, Dialog dialog, QuestionInSet question,
                    DataValidation dataValidation) {
        this.id = id;
        this.label = label;
        this.value = value;
        this.dialog = dialog;
        this.question = question;
        this.dataValidation = dataValidation;
    }

    @Id
    @SequenceGenerator(name = "q_response_id_seq",
            sequenceName = "q_response_id_seq",
            allocationSize = 1, initialValue = 1)
    // Set allocationSize and initialValue
    // to let sequence increment following DB.
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "q_response_id_seq")
    @Column(name = "q_response_id", columnDefinition = "integer")
    public Long getResponseId() {
        return this.responseId;
    }

    public void setResponseId(Long responseId) {
        this.responseId = responseId;
    }

    @Column(name = "id", length = 256)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "label", length = 256)
    public String getLabel() {
        return this.label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    //    @Column(name = "_VALUE")
    @Column(name = "value")
    public String getValue() {
        return this.value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dinstforrespassoc_q_dinst_id_o")
    public Dialog getDialog() {
        return dialog;
    }

    public void setDialog(Dialog dialog) {
        this.dialog = dialog;
    }
/**
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pagequestionassoc_q_page_question_id_oid")
    public QuestionInSet getQuestionInSet() {
        return questionInSet;
    }

    public void setQuestionInSet(QuestionInSet questionInSet) {
        this.questionInSet = questionInSet;
    }
**/
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "datavalidationassoc_code_oid")
    public DataValidation getDataValidation() {
        return this.dataValidation;
    }

    public void setDataValidation(DataValidation dataValidation) {
        this.dataValidation = dataValidation;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "pgqassoc_q_pg_q_id_oid")
    public QuestionInSet getQuestion() {
        return this.question;
    }

    public void setQuestion(QuestionInSet question) {
        this.question = question;
    }
}